package org.atlantis.grosbeak.cable;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.atlantis.grosbeak.lang.Exceptions;

class DefaultExceptionHandler implements ExceptionHandler {

	public void handle(HttpServletRequest request,
			HttpServletResponse response, Exception e) throws CableException {
		try {
			PrintWriter out = response.getWriter();
			out
					.write("<html><head><title>Exception! - Grosbeak.Cable</title></head><body><pre>");
			e.printStackTrace(out);
			out.write("</pre></body></html>");
			out.flush();
			out.close();
		} catch (IOException e1) {
			throw Exceptions.wrapThrow(CableException.class, e1);
		}
	}
}
